#version 330 core
out vec4 FragColor;

in vec3 Normal;
in vec3 FragPos;

uniform vec3 lightPos;      //灯光位置
uniform vec3 lightColor;    //灯光颜色
uniform vec3 objectColor;   //物体位置

void main()
{
    // ambient
    float ambientStrength = 0.1;                   //环境光强度
    vec3  ambient = ambientStrength * lightColor;  //计算后的环境光颜色

    // diffuse
    vec3 norm = normalize(Normal);
    vec3 lightDir = normalize(lightPos - FragPos); //光照方向
    float diff = max(dot(norm, lightDir), 0.0);    //光照强度
    vec3  diffuse = diff * lightColor;             //计算后的漫反射灯光颜色

    vec3 result = (ambient + diffuse) * objectColor;//计算后的物体实际颜色
    FragColor = vec4(result, 1.0);
}